# coding: utf-8
from layer_naive import *
apple = 100
apple_num = 2
tax = 1.1

mul_apple_layer = MulLayer()
# print(mul_apple_layer.x)
# print(mul_apple_layer.y)
# print(dir(mul_apple_layer))

# 这里的x表示不考虑税率需要的价格。
# 这里的y表示在原来价格的多少倍是实际需要支付的金额


print("-"*60)
#------------------上面看下建立对象以后的情况-----------------------------


mul_tax_layer = MulLayer()

# forward
apple_price = mul_apple_layer.forward(apple, apple_num)
# apple*apple_num
print("apple_price=",apple_price)
price = mul_tax_layer.forward(apple_price, tax)
# apple_price*tax
print("交税后的总价钱price=",price)

# backward
dprice = 1
print("dprice=",dprice)
print("mul_tax_layer.x=",mul_tax_layer.x)#200
print("mul_tax_layer.y=",mul_tax_layer.y)#1.1
dapple_price, dtax = mul_tax_layer.backward(dprice)
print("-------------------1-------------------------")
print("dapple_price=",dapple_price)#1.1 
print("dtax=",dtax)
print("-------------------测试以前-------------------------")
print("mul_apple_layer.x=",mul_apple_layer.x)#100
print("mul_apple_layer.y=",mul_apple_layer.y)#2
dapple, dapple_num = mul_apple_layer.backward(dapple_price)
#这里的backward函数只有链式法则的效果，并没有经典神经网络中权重修正的效果
# 这里的苹果的个数、税率都是在模仿经典神经网络中的每一层的权重


print("dApple:", dapple)#2.2
print("dApple_num:", int(dapple_num))